
//主界面表加实时天气
void  drawWatherTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
  //当前时间
  String timenow = String(hour()) + ":" + twoDigits(minute()) + ":" + twoDigits(second());
  display->setTextAlignment(TEXT_ALIGN_LEFT);
  //display->setTextAlignment(TEXT_ALIGN_CENTER);
  display->setFont(ArialMT_Plain_24);
  display->drawString(0 + x, 5 + y,  timenow );

  // 天气图标
  display->setFont(Meteocons_Plain_21);
  String wcode = getMeteoconIcon(WATHER_CODE);
  display->drawString( 106 + x, 5 + y,  wcode);


  // 星期
  String week = WDAY_NAMES[weekday() - 1];
  display->setFont(ArialMT_Plain_16);
  display->drawString(0 + x, 28 + y,  week);

  //d当前温度
  display->drawString(101 + x, 28 + y,  String(WATHER_TEMPERATURE) + "°");

  // 年月日
  //  display->setTextAlignment(TEXT_ALIGN_LEFT);
  display->setFont(ArialMT_Plain_10);
  String date =  String (year()) + "-" + MONTH_NAMES[month() - 1] + "-" + String( day()) ;
  display->drawString(38 + x, 32 + y,  date);


  // 画一条分割线
  display->drawLine(0 + x, 46 + y, 128 + x, 46 + y);


  // 汉字天气
  drawWather(WATHER_CODE, 5 + x, 48 + y);

  // 天气更新时间
  display->setTextAlignment(TEXT_ALIGN_RIGHT);
  //display->setTextAlignment(TEXT_ALIGN_CENTER);
  display->setFont(ArialMT_Plain_10);
  display->drawString(128 + x, 54 + y,  WATHER_UPDATE_TIME );


}
String twoDigits(int digits) {
  if (digits < 10) {
    String i = '0' + String(digits);
    return i;
  }
  else {
    return String(digits);
  }
}
//生活信息界面

void lifeinfo(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y ) {

  display->drawXbm(    x,  14 + y, 16, 16  ,  SHENG_16  );
  display->drawXbm(    x,  42 + y, 16, 16  ,  HUO_16  );

  _y = _y + 0.01;
  int flag = (int)_y / 3;

  display->setFont(ArialMT_Plain_10);
  display->setTextAlignment(TEXT_ALIGN_RIGHT);
  display->drawString(128 + x, 0 + x,  String(flag));

  if (flag == 0)
  {
    lifeCarw(20 + x, 8 + y  );
    lifeDRESSING(20 + x, 28 + y  );
    lifeFLU(20 + x, 48 + y  );
  }
  else if (flag == 1)
  {
    lifeSport(20 + x, 8 + y  );
    lifeTRAVEL(20 + x, 28 + y  );
    lifeUV(20 + x, 48 + y  );
  }
  if (flag >= 2)
    _y = 0;

}
//界面3今日天气详细
void watherToday(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y ) {

  display->drawXbm(    x,  14 + y, 16, 16  ,  JIN_16  );
  display->drawXbm(    x,  42 + y, 16, 16  ,  RI_16  );


  display->setTextAlignment(TEXT_ALIGN_LEFT);
  display->setFont(ArialMT_Plain_16);
  _y = _y + 0.01;
  int flag = (int)_y / 3;
  if (flag == 0)
  {
    display->drawXbm(  20 + x,  8 + y, 16, 16  ,  BAI_16  );
    display->drawXbm(  37 + x,  8 + y, 16, 16  ,  TIAN_16  );
    drawWather(  TODAY_DAY_CODE , 60 + x,  8 + y       );
    display->drawXbm(  20 + x,  28 + y, 16, 16  ,  YE_16  );
    display->drawXbm(  37 + x,  28 + y, 16, 16  ,  WAN_16  );
    drawWather(  TODAY_NIGHT_CODE , 60 + x,  28 + y       );
    display->drawXbm(  20 + x,  48 + y, 16, 16  ,  WEN_16  );
    display->drawXbm(  37 + x,  48 + y, 16, 16  ,  DU_16  );
    display->drawString(60 + x, 48 + y,  TODAY_LOW_TEMPERATURE + "° - " + TODAY_HIGH_TEMPERATURE + "°");
  }  else if (flag == 1)
  {
    ///////////////////////////////第二页

    display->drawXbm(  20 + x,  8 + y, 16, 16  ,  FENG  );
    display->drawXbm(  37 + x,  8 + y, 16, 16  ,  SU_16  );
    display->drawString(60 + x, 8 + y,  TODAY_WIND_SPEED );

    display->drawXbm(  20 + x,  28 + y, 16, 16  ,  FENG  );
    display->drawXbm(  37 + x,  28 + y, 16, 16  ,  LI_16  );
    display->drawString(60 + x, 28 + y,  TODAY_WIND_SCALE );

    display->drawXbm(  20 + x,  48 + y, 16, 16  ,  FENG  );
    display->drawXbm(  37 + x,  48 + y, 16, 16  ,  XIANG_16  );
    drawWIND(   60 + x,  48 + y,     TODAY_WIND_DIRECTION );


  }
  else if (flag == 2) {
    display->drawXbm(  20 + x,  8 + y, 16, 16  ,  SHI1_16  );
    display->drawXbm(  37 + x,  8 + y, 16, 16  ,  DU_16  );
    display->drawString(60 + x, 8 + y,  TODAY_HUMIDITY );
  }
  if (flag >= 3)
    _y = 0;
}

//界面5 天气预测明天后天
void watherTomorrowAndAfterTomorrow(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y ) {
  display->setTextAlignment(TEXT_ALIGN_LEFT);
  display->setFont(ArialMT_Plain_16);
  display->drawString(2 + x, 8 + y,  TOMORROW_DATE );
  drawWather(  TOMORROW_DAY_CODE ,  2 + x,  28 + y );
  display->drawString(2 + x, 48 + y,  TOMORROW_LOW_TEMPERATURE + "° - " + TOMORROW_HIGH_TEMPERATURE + "°" );

  display->drawLine(64 + x, 8 + y, 64 + x, 60 + y);

  display->setTextAlignment(TEXT_ALIGN_RIGHT);
  display->drawString(126 + x, 8 + y,  AFTER_TOMORROW_DATE );
  drawWatherRight(  AFTER_TOMORROW_DAY_CODE ,  2 + x,  28 + y );
  display->drawString(126 + x, 48 + y,  AFTER_TOMORROW_LOW_TEMPERATURE + "° - " + AFTER_TOMORROW_HIGH_TEMPERATURE + "°" );


}

//界面4 大数字时钟
void bigClock (OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y ) {
  display->setTextAlignment(TEXT_ALIGN_LEFT);
  display->setFont(Ultra_Regular_40)  ;
  String h1 = "0";
  String h2 = "0";
  if (hour() > 9)
  {
    h1 =  String(hour()).substring(1, 0);
    h2 =  String(hour()).substring(1, 2);
  }
  else
  {
    h2 = String(hour());
  }
  String m1 = "0";
  String m2 = "0";
  if (minute() > 9)
  {
    m1 =  String(minute()).substring(1, 0);
    m2 =  String(minute()).substring(1, 2);
  }
  else
  {
    m2 = String(minute());
  }


  display->drawString(3 + x, 10 + y, h1);
  display->drawString(24 + x, 10 + y, h2);
  display->drawString(53 + x, 10 + y, ".");
  display->setTextAlignment(TEXT_ALIGN_RIGHT);
  //  display->drawString(128 + x, 10 + y,  twoDigits(minute()));

  display->drawString(98 + x, 10 + y, m1);
  display->drawString(125 + x, 10 + y, m2);
  display->setFont(ArialMT_Plain_10);
  display->drawString(128 + x, 54 + y, String(second()));



}

//欢迎页面
void welcome() {
  display.setFont(ArialMT_Plain_24);
  display.setTextAlignment(TEXT_ALIGN_CENTER);
  display.drawString(64, 12, "welcome...");
  display.setTextAlignment(TEXT_ALIGN_RIGHT);
  display.drawString(128, 38, "linking...");
}
